package com.db.nio;

import java.io.*;

public class FileCopyIO extends AbstractCopy {
    public static void main(String[] args) {
        System.out.println("started");

        long startTime = System.currentTimeMillis();

        try (InputStream inputStream = new FileInputStream(FILE_1);
             OutputStream outputStream = new FileOutputStream(FILE_2)) {

            byte[] data = new byte[BUFFER_SIZE];
            while ((inputStream.read(data)) != -1) {
                outputStream.write(data);
            }

            long time = System.currentTimeMillis() - startTime;

            System.out.println("success");
            System.out.println(time + "ms");

        } catch (IOException e) {
            System.out.println("input output exception");
        }
    }
}
